<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
	<title></title>
	<style type="text/css">
		#test{
			width:1px;
			height:17px;
			background:#0f0;
		}
	</style>
</head>
<body>
	<div id="test">0%</div>
	<input type="button" value="Run" id="run"/>


	window.requestAnimationFrame() 方法告诉浏览器您希望执行动画，并请求浏览器调用指定的函数在下一次重绘之前更新动画。该方法将在重绘之前调用的回调作为参数。
</body>
<script type="text/javascript">
	window.requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame; //兼容个主流浏览器
	var start = null;
	var ele = document.getElementById("test");  //获取元素
	var progress = 0;

	function step(timestamp) {
	    progress += 1;
	    ele.style.width = progress + "%";
	    ele.innerHTML=progress + "%";
	    if (progress < 100) {
	        requestAnimationFrame(step);
	    }
	}
	requestAnimationFrame(step);
	document.getElementById("run").addEventListener("click", function() {
	    ele.style.width = "1px";
	    progress = 0;
	    requestAnimationFrame(step);
	}, false);
</script>
</html>